<div class="layui-fluid">
    <div class="layui-breadcrumb jy-breadcrumb">

    </div>
    <div class="layui-card">
        <div class="layui-form pd15" id="editHtml" lay-filter="LAY-list-form">


        </div>
    </div>
</div>


<style>
    .layui-form-select {
        width: 100%;
    }
</style>
<script type="text/html" id="editTp">

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">最后编辑人</label>
            <div class="layui-input-block">
                <input type="text" name="operator" value="{{d.r.operator||''}}" placeholder="" autocomplete="off"
                       class="layui-input" readonly>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">编辑时间</label>
            <div class="layui-input-inline">
                <input type="text" name="modification_time" value="{{d.r.modification_time||''}}" placeholder=""
                       autocomplete="off" class="layui-input" readonly>
            </div>
        </div>
    </div>

    {{# for(var i in d.list){ var data1=d.list[i]; }}

    {{# if(data1.type==1){ }}
    <div class="layui-input-block">
        <input type="hidden" name="id[]" value="{{data1.id}}">
        <input type="hidden" name="make_type[]" value="">
        <input type="hidden" name="symbol[]" value="">
        <input type="hidden" name="num[]" value="">
        <input type="checkbox" name="status[]" lay-skin="primary" {{data1.status==1?'checked':''}}>
        交接类型为:
        <div class="layui-input-inline">
            <input type="text" style="width: 250px" name="describe[]" value="{{data1.describe}}" placeholder=""
                   autocomplete="off" class="layui-input">
        </div>
        审核通过 (多个用空格或逗号隔开)
    </div>
    <br/>
    {{# }else if(data1.type==2){ }}

    <div class="layui-input-block">
        <input type="hidden" name="id[]" value="{{data1.id}}">
        <input type="checkbox" name="status[]" lay-skin="primary" {{data1.status==1?'checked':''}}>
        <input type="hidden" name="describe[]" value="">
        制作类型为:
        <div class="layui-input-inline " style="width: 120px;">
            <select name="make_type[]" lay-filter="make_type" class="make_type">
                <option value="1" {{data1.make_type==1?'selected':''}}>资料包</option>
                <option value="2" {{data1.make_type==2?'selected':''}}>样品</option>
            </select>
        </div>
        <div class="layui-input-inline symbol" style="width: 80px;">
            <select name="symbol[]">
                <option value=">" {{data1.symbol=='>'?'selected':''}}>></option>
                <option value="<" {{data1.symbol=='<'?'selected':''}}><</option>
                <option value=">=" {{data1.symbol=='>='?'selected':''}}>>=</option>
                <option value="<=" {{data1.symbol=='<='?'selected':''}}><=</option>
                <option value="=" {{data1.symbol=='='?'selected':''}}>=</option>
            </select>
        </div>
        <div class="layui-input-inline num" style="width: 80px">
            <input type="text" name="num[]" value="{{data1.num}}" class="layui-input">
        </div>
        审核不通过
    </div>
    {{# } }}

    {{# } }}
    <div class="  layui-item">
        <label class="layui-form-label"> </label>
        <button class="layui-btn editSkuSubmit">保存</button>
        (勾选代表启用该规则)
    </div>
</script>
<script>
    layui.use(['admin', 'table', 'form', 'toolJ', 'formSelects', 'laytpl','ajaxCascader'], function () {
        var $ = layui.$
            , admin = layui.admin
            , view = layui.view
            , table = layui.table
            , laytpl = layui.laytpl
            , formSelects = layui.formSelects
            , toolJ = layui.toolJ
            , cascader = layui.ajaxCascader
            , form = layui.form;
        //监听提交sku编辑
        $('body').on('click', '.editSkuSubmit', function (data) {
            var field = form.val("LAY-list-form");
            if (field['status[1]'] == 'on') {
                if (field['make_type[1]'] == 2) {
                    if (field['num[1]'] > 0) {
                    } else {
                        layer.alert('样品数量要大于0');
                        return false;
                    }
                }
            }
            toolJ.ajax({"data": field, 'url': '/index/Handoverreview/edit'});
        });
        toolJ.ajax({'url': '/index/Handoverreview/index'}, function (res) {
            var getTpl = editTp.innerHTML;
            laytpl(getTpl).render(res.data, function (html) {
                $('#editHtml').html(html);
                if($(".make_type").val()==2){
                    $(".symbol").show();
                    $(".num").show();
                }else{
                    $(".symbol").hide();
                    $(".num").hide();
                }
                form.render(null, 'LAY-list-form');
            })
            form.on('select(make_type)', function (data) {
                if (data.value == 2) {
                    $(".symbol").show();
                    $(".num").show();
                } else {
                    $(".symbol").hide();
                    $(".num").hide();
                }
            });
        });

    });
</script>